<html>
<head><meta charset="utf-8"><title>generics · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/generics.html">generics</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="183223973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/generics/near/183223973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Gaynor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/generics.html#183223973">(Dec 12 2019 at 02:41)</a>:</h4>
<p>I have a rather elementary question about the compiler. If you've got crate A, and it instantiates Vec&lt;T&gt;, and then you have crate B, and it _also_ instantiates Vec&lt;T&gt; does the compiler emit Vec&lt;T&gt; in both A and B, or is it able to avoid re-instantiating it in B and just reusing A's?</p>



<a name="183235434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/generics/near/183235434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/generics.html#183235434">(Dec 12 2019 at 07:55)</a>:</h4>
<p>It does it in both unless one crate is a dependency of the other</p>



<a name="183243140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/generics/near/183243140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/generics.html#183243140">(Dec 12 2019 at 09:39)</a>:</h4>
<p>Does that also mean that you get two copies of the code in the end binary?</p>



<a name="183244023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/generics/near/183244023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/generics.html#183244023">(Dec 12 2019 at 09:51)</a>:</h4>
<p>link time opimizations usually kill it</p>



<a name="183254528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/generics/near/183254528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Gaynor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/generics.html#183254528">(Dec 12 2019 at 12:39)</a>:</h4>
<p>Got it, thanks.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>